<html>
    <head>
        <link href="<?echo base_url();?>css/automat_details.css" rel="stylesheet" type="text/css"/>
        <script src="<?echo base_url();?>jscripts/automat_details_ajax_view.js" type="text/javascript"></script>
        <script>
            $("#automate-tabs").tabs();
            var data = {
                reloadUrl : '<?echo base_url();?>automat',
                deleteUrl : '<?echo base_url();?>automat/DeleteAutomat',
                editWaresUrl : '<?echo base_url();?>ware'
            };
            $(document).ready(function(){AutomatDetailsAjaxView.init(data);});
        </script>
    </head>
    <body>
        <div id="automate-tabs">
            <div id="b-automate-edit">
                <?
                    $stateText = "YES";
                    $stateClass = "text-yes";
                    if($automate['Serviceability'] == 0){
                        $stateText = "NO";
                        $stateClass = "text-no";
                    }
                ?>
                <input type="hidden" name="AutomatId" value="<?echo $automate['AutomatId'];?>"/>
                <div class="bold">ID: <?echo $automate['AutomatId'];?></div>
                <div class="info">
                    <label>Info: </label> <input type="hidden" name="Info" value='<?echo $automate['Info'];?>'/>
                    <?echo $automate['Info'];?>
                </div>
                <br/>
                <div class="bold">Balance: <?echo $automate['Balance'];?></div>
                <div>Connect time: <?echo $automate['ConnectTime'];?></div>
                <br/>
                <div>Latitude: <?echo $automate['Latitude'];?></div>
                <div>Longitude: <?echo $automate['Longitude'];?></div>
                <div>IP: <?echo $automate['IP'];?></div>
                <div class='<?echo $stateClass;?>'>
                    Serviceability: <?echo $stateText?>
                </div>
                <div id="b-delete-automate">
                    <img id="delete-automat-button-img" src="<?echo base_url();?>images/trash-empty.png">
                </div>
            </div>
            <div id="close-button">
                <img id="close-button-img" src="<?echo base_url();?>images/close.png" alt="close"/>
            </div>
            <ul>
                <li><a href="#tabs-wares">Wares</a></li>
                <li><a href="#tabs-log">Log</a></li>
            </ul>
            <div id="tabs-wares">
                <button id="wares-edit-button">Edit</button>
                <table id="wares-table" cellspacing=1>
                    <tr>
                        <th>Ware ID</th>
                        <th>Price</th>
                        <th>Amount</th>
                        <th>Prod. code</th>
                        <th>Prod. name</th>
                        <th>Can sell</th>
                        <th>Sell from</th>
                        <th>Sell to</th>
                    </tr>
                    <?
                        foreach($wares as $w){
                            //WareId, Price, Amount, AutomatId, ProductCode, CanSell, SellFrom, SellTo
                            echo"<tr>
                                <td>".$w['WareId']."</td>
                                <td>".$w['Price']."</td>
                                <td>".$w['Amount']."</td>
                                <td>".$w['ProductCode']."</td>
                                <td>".$w['Name']."</td>
                                <td>".$w['CanSell']."</td>
                                <td>".$w['SellFrom']."</td>
                                <td>".$w['SellTo']."</td>
                                </tr>";
                        }
                    ?>
                </table>
            </div>
            
            <div id="tabs-log">
                <table id="log-table" cellspacing=1>
                    <tr>
                        <th>Ware Id</th>
                        <th>DateTime</th>
                    </tr>
                    <?
                        foreach($log as $l){
                            //AutomatId, WareId, DateTime
                            echo"<tr>
                                <td>".$l['WareId']."</td>
                                <td>".$l['DateTime']."</td>
                                </tr>";
                        }
                    ?>
                </table>
            </div>
        </div>
   </body>
</html>